<template>
  <div class="kaocha-detail">
    <el-breadcrumb separator=">">
      <el-breadcrumb-item :to="{ path: '/' }">系统首页</el-breadcrumb-item>
      <el-breadcrumb-item :to="{ path: '/selection' }">干部选任</el-breadcrumb-item>
      <el-breadcrumb-item :to="{ path: '/selection/kaocha' }">考察</el-breadcrumb-item>
    </el-breadcrumb>
    <section class="wboxnoborder">
      <div :style="'height:'+tableHeight+'px'">
        <el-scrollbar style="height: calc(100% + 16px);">
          <div v-show="pageloading">读取中...</div>
          <el-form v-show="!pageloading" ref="kaochaForm"
            :model="kaochaForm"
            label-width="120px"
            label-position="right"
            :inline="true"
            style="margin:15px;"
            :rules="formRules">
            <el-form-item label="姓名">
              <span class="selectioncontent">
                {{realName}}
              </span>
            </el-form-item>
            <el-form-item label="动议岗位单位">
              <span class="selectioncontent">
                {{unitName}}
              </span>
            </el-form-item>
            <el-form-item label="动议岗位职务">
              <span class="selectioncontent">
                {{jobName}}
              </span>
            </el-form-item>
            <el-form-item label="动议岗位职级">
              <span class="selectioncontent">
                {{jobLevel}}
              </span>
            </el-form-item>
            <div style="clear:both"></div>
            <div v-show="!params.edit">
              <el-form-item label="考察范围" prop="examinationRange" :rules="[{ required: true, message: '请选择考察范围', trigger: 'blur' }]">
                <el-select placeholder="请选择" style="width:800px"
                  v-model="kaochaForm.examinationRange"
                  multiple
                  filterable
                  allow-create
                  default-first-option
                  >
                  <el-option
                    v-for="(item,index) in confines"
                    :key="index"
                    :label="item.label"
                    :value="item.value">
                  </el-option>
                </el-select>
              </el-form-item>
              <el-form-item label="考察时间" prop="date">
                <el-date-picker
                  v-model="kaochaForm.date"
                  type="daterange"
                  align="right"
                  unlink-panels
                  range-separator="至"
                  start-placeholder="开始日期"
                  end-placeholder="结束日期"
                  :picker-options="pickerOptions"
                  value-format="yyyy-MM-dd"
                  @change="setDate2"
                >
                </el-date-picker>
              </el-form-item>
              <div style="clear:both"></div>
              <el-form-item label="考察结果" prop="num">
                <el-input-number v-model="kaochaForm.num" :min="0"></el-input-number>
                人参加考察谈话。其中
              </el-form-item>
              <el-form-item label="" prop="num2">
                <el-input-number v-model="kaochaForm.num2" :min="0"></el-input-number>
                人同意。
              </el-form-item>
              <el-form-item label="" prop="num3">
                <el-input-number v-model="kaochaForm.num3" :min="0"></el-input-number>
                人不同意。
              </el-form-item>
              <el-form-item label="" prop="num4">
                <el-input-number v-model="kaochaForm.num4" :min="0"></el-input-number>
                人弃权。
              </el-form-item>
              <el-table :data="ftsb" v-loading="loading" style="margin-bottom:15px" border >
                <el-table-column label="凡提四必情况">
                  <el-table-column label="查核干部档案">
                    <template slot-scope="scope">
                      {{scope.row.ftsb1}}
                    </template>
                  </el-table-column>
                  <el-table-column label="查核有关事项">
                    <template slot-scope="scope">
                      {{scope.row.ftsb2}}
                    </template>
                  </el-table-column>
                  <el-table-column label="征求纪检监察部门意见">
                    <template slot-scope="scope">
                      {{scope.row.ftsb3}}
                    </template>
                  </el-table-column>
                  <el-table-column label="线索举报调查">
                    <template slot-scope="scope">
                      {{scope.row.ftsb4}}
                    </template>
                  </el-table-column>
                </el-table-column>
              </el-table>
              <el-form-item label="是否和本人谈话" prop="sfhbrth" label-width="200px">
                <el-checkbox v-model="kaochaForm.sfhbrth" style="width:200px;">是</el-checkbox>
              </el-form-item>
              <div style="clear:both"></div>
              <el-form-item label="重要情况" prop="zyqk">
                <el-input v-model="kaochaForm.zyqk" style="width:800px"></el-input>
              </el-form-item>
              <div style="clear:both"></div>
              <el-form-item label="任前报告情况" prop="rqbg">
                <el-input v-model="kaochaForm.rqbg" style="width:800px"></el-input>
              </el-form-item>
              <div style="clear:both"></div>
              <el-form-item>
                <el-button type="primary" style="margin-left:120px" @click="exportdoc">生成考察素材模板</el-button>
                <el-button type="primary" @click="exportdoc2">导出档案查核表</el-button>
              </el-form-item>
              <div style="clear:both"></div>
              <el-form-item label="上传附件" prop="file">
                <el-upload
                  class="upload-demo"
                  :action="this.$http.defaults.baseURL+this.$http.defaults.selectionAPI +'api/gen/file/upload/'"
                  :on-success="handleUploadSucc"
                  :on-remove="handleRemove"
                  :before-remove="beforeRemove"
                  :on-error='uploadError'
                  :multiple="true"
                  :file-list="fileList">
                  <el-button type="primary">点击上传</el-button>
                </el-upload>
              </el-form-item>
              <div style="clear:both"></div>
              <el-form-item label="考察组审核人" prop="hcr">
                <el-input v-model="kaochaForm.hcr"></el-input>
              </el-form-item>
              <el-form-item label="审核时间" prop="date2">
                <el-date-picker type="date" placeholder="选择时间" v-model="kaochaForm.date2" style="width: 100%;" value-format="yyyy-MM-dd"></el-date-picker>
              </el-form-item>
              <div style="clear:both"></div>
              <el-form-item label="是否存在问题" prop="problem">
                <el-radio-group v-model="kaochaForm.problem">
                  <el-radio :label="1">是</el-radio>
                  <el-radio :label="2">否</el-radio>
                </el-radio-group>
              </el-form-item>
              <el-form-item label="存在问题" v-if="kaochaForm.problem == 1">
                <el-input v-model="kaochaForm.hasproblem" style="width:800px"></el-input>
              </el-form-item>
            </div>
            <div v-show="params.edit">
              <el-form-item label="考察范围">
                <span class="selectioncontent">
                  <span v-for="(item,index) in kaochaForm.examinationRange" :key="index"><span v-if="index>0">、</span>{{item}}</span>
                </span>
              </el-form-item>
              <el-form-item label="考察时间">
                <span class="selectioncontent">
                  {{kaochaForm.date}}至
                  {{kaochaForm.finishTime}}
                </span>
              </el-form-item>
              <div style="clear:both"></div>
              <el-form-item label="考察结果">
                <span class="selectioncontent">
                  {{kaochaForm.num}}
                </span>
                人参加考察谈话。其中
                <span class="selectioncontent">
                  {{kaochaForm.num2}}
                </span>
                人同意。
                <span class="selectioncontent">
                  {{kaochaForm.num3}}
                </span>
                人不同意。
                <span class="selectioncontent">
                  {{kaochaForm.num4}}
                </span>
                人弃权。
              </el-form-item>
              <el-table :data="ftsb" v-loading="loading" style="margin-bottom:15px" border >
                <el-table-column label="凡提四必情况">
                  <el-table-column label="查核干部档案">
                    <template slot-scope="scope">
                      {{scope.row.ftsb1}}
                    </template>
                  </el-table-column>
                  <el-table-column label="查核有关事项">
                    <template slot-scope="scope">
                      {{scope.row.ftsb2}}
                    </template>
                  </el-table-column>
                  <el-table-column label="征求纪检监察部门意见">
                    <template slot-scope="scope">
                      {{scope.row.ftsb3}}
                    </template>
                  </el-table-column>
                  <el-table-column label="线索举报调查">
                    <template slot-scope="scope">
                      {{scope.row.ftsb4}}
                    </template>
                  </el-table-column>
                </el-table-column>
              </el-table>
              <el-form-item label="是否和本人谈话" label-width="200px">
                <span class="selectioncontent">
                  是
                </span>
              </el-form-item>
              <div style="clear:both"></div>
              <el-form-item label="重要情况">
                <span class="selectioncontent">
                  {{kaochaForm.zyqk}}
                </span>
              </el-form-item>
              <div style="clear:both"></div>
              <el-form-item label="任前报告情况">
                <span class="selectioncontent">
                  {{kaochaForm.rqbg}}
                </span>
              </el-form-item>
              <div style="clear:both"></div>
              <el-form-item>
                <el-button type="primary" style="margin-left:120px" @click="exportdoc">生成考察素材模板</el-button>
                <el-button type="primary" @click="exportdoc2">导出档案查核表</el-button>
              </el-form-item>
              <div style="clear:both"></div>
              <el-form-item label="附件" prop="files">
                <div  v-for="(item, index) of files" :key="index">
                  <a :href="$http.defaults.baseURL+$http.defaults.selectionAPI+'api/gen/file/download?id='+item.id">{{item.fileName}}.{{item.fileType}}</a>
                </div>
              </el-form-item>
              <div style="clear:both"></div>
              <el-form-item label="考察组审核人">
                <span class="selectioncontent">
                  {{kaochaForm.hcr}}
                </span>
              </el-form-item>
              <el-form-item label="审核时间">
                <span class="selectioncontent">
                  {{kaochaForm.date2}}
                </span>
              </el-form-item>
              <div style="clear:both"></div>
              <el-form-item label="是否存在问题">
                <span class="selectioncontent" v-if="kaochaForm.problem == 1">是</span>
                <span class="selectioncontent" v-else>否</span>
              </el-form-item>
              <el-form-item label="存在问题" v-if="kaochaForm.problem == 1">
                <span class="selectioncontent">
                  {{kaochaForm.hasproblem}}
                </span>
              </el-form-item>
            </div>
            <div style="clear:both"></div>
            <el-form-item label="考察组成员" prop="name">
              <div v-show="params.edit">{{kaochaForm.name}}</div>
              <el-select placeholder="请选择" style="width:800px" v-show="!params.edit"
                v-model="workgrouparr"
                multiple
                filterable
                allow-create
                default-first-option
                @change="selectUsersChange">
                <el-option-group
                  v-for="(group,index) in allUser"
                  :key="index"
                  :label="group.label">
                  <el-option
                    v-for="(item,subindex) in group.options"
                    :key="subindex"
                    :label="item.label"
                    :value="item.value">
                  </el-option>
                </el-option-group>
              </el-select>
            </el-form-item>
            <div style="clear:both"></div>
            <el-form-item label="备注">
              <el-input v-model="kaochaForm.beizhu" style="width:800px"></el-input>
            </el-form-item>
            <div style="clear:both"></div>

            <div v-if="inRoles(userRoles,'ROLE_chuzhang')">
              <el-form-item v-if="params.edit">
                <!-- <el-button type="primary" @click="onSubmit(1)" style="margin-left:120px;" :loading="submitloading">保存并重新发起流转</el-button> -->
                <el-button type="success" style="margin-left:120px;" @click="onSubmit(2)" :loading="submitloading">考察完成通过提请审议</el-button>
                <el-popconfirm title="确认进行此操作吗？" @confirm="onSubmit(3)">
                  <el-button type="danger" :loading="submitloading" slot="reference">考察未通过</el-button>
                </el-popconfirm>
              </el-form-item>
              <el-form-item v-else>
                <!-- <el-button @click="onSubmit(0)" style="margin-left:120px;" :loading="submitloading">暂存</el-button> -->
                <el-button type="primary" style="margin-left:120px;" @click="onSubmit(1)" :loading="submitloading">办理完成</el-button>
              </el-form-item>
            </div>
            <div v-if="inRoles(userRoles,'ROLE_banshirenyuan')">
              <el-form-item>
                <!-- <el-button @click="onSubmit(0)" style="margin-left:120px;" :loading="submitloading">暂存</el-button> -->
                <el-button type="primary" style="margin-left:120px;" @click="onSubmit(1)" :loading="submitloading">办理完成并发送处长</el-button>
              </el-form-item>
            </div>
          </el-form>
        </el-scrollbar>
      </div>
    </section>
  </div>
</template>

<script>
export default {
  name: 'kaocha-detail',
  data () {
    var checkTrue = (rule, value, callback) => {
      if (!value) {
        return callback(new Error('此项必须勾选'))
      } else {
        callback()
      }
    }
    return {
      pickerOptions: {
        shortcuts: [{
          text: '最近一周',
          onClick (picker) {
            const end = new Date()
            const start = new Date()
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 7)
            picker.$emit('pick', [start, end])
          }
        }, {
          text: '最近一个月',
          onClick (picker) {
            const end = new Date()
            const start = new Date()
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)
            picker.$emit('pick', [start, end])
          }
        }]
      },
      confines: [],
      realName: '',
      unitName: '',
      jobLevel: '',
      jobName: '',
      workgrouparr: [],
      allUser: [],
      userRoles: '',
      submitloading: false,
      pageloading: false,
      loading: false,
      tableHeight: 100,
      params: {},
      kaochaForm: {
        name: '',
        date: '',
        date2: '',
        num: 0,
        num2: 0,
        num3: 0,
        num4: 0,
        beizhu: '',
        zyqk: '',
        sfhbrth: '',
        rqbg: '',
        hcr: '',
        problem: '',
        hasproblem: ''
      },
      ftsb: [
        {
          ftsb1: '',
          ftsb2: '',
          ftsb3: '',
          ftsb4: ''
        }
      ],
      files: [],
      fileList: [],
      noticeTit: '办理提示',
      noticeData: [
      ],
      selectData: {
        hjData: [
        ],
        szData: [
        ],
        cnData: [],
        yyData: []
      },
      formRules: {
        name: [{ required: true, message: '考察组成员不能为空', trigger: 'blur' }],
        date: [{ required: true, message: '请选择考察时间', trigger: 'blur' }],
        num: [{ required: true, message: '参加考察谈话总人数不能为空', trigger: 'blur' }, { type: 'number', min: 1, message: '参加考察谈话总人数不能为0', trigger: 'blur' }],
        num2: [{ required: true, message: '同意人数不能为空', trigger: 'blur' }],
        num3: [{ required: true, message: '不同意人数不能为空', trigger: 'blur' }],
        num4: [{ required: true, message: '弃权人数不能为空', trigger: 'blur' }],
        zyqk: [{ required: true, message: '重要情况不能为空', trigger: 'blur' }],
        sfhbrth: [{ required: true, message: '请确认是否和本人谈话', trigger: 'blur' }, { validator: checkTrue, trigger: 'blur' }],
        rqbg: [{ required: true, message: '任前报告不能为空', trigger: 'blur' }],
        hcr: [{ required: true, message: '考察组审核人不能为空', trigger: 'blur' }],
        date2: [{ required: true, message: '请选择审核时间', trigger: 'blur' }],
        problem: [{ required: true, message: '请选择是否存在问题', trigger: 'blur' }]
      }
    }
  },
  methods: {
    setDate2 (val) {
      this.kaochaForm.date2 = val[0]
    },
    selectUsersChange (data) {
      if (data && data.length > 0) {
        this.kaochaForm.name = data[0]
      } else {
        this.kaochaForm.name = ''
      }
      for (let i = 0; i < data.length; i++) {
        if (i > 0) {
          this.kaochaForm.name = this.kaochaForm.name + '、' + data[i]
        }
      }
    },
    getAllUser () {
      this.$http
        .get(this.$http.defaults.selectionAPI + `api/selection/auth/getUsersGroupByUnitname`)
        .then(response => {
          if (response.data.success) {
            let options = []
            let suboptions = []
            for (let key in response.data.result) {
              suboptions = []
              for (let item of response.data.result[key]) {
                suboptions.push({value: item.truename, labal: item.truename})
              }
              options.push({label: key, options: suboptions})
            }
            this.allUser = options
          } else {
            console.log('获取失败')
          }
        })
        .catch(function (error) {
          console.log(error)
        })
    },
    exportdoc () {
      window.open(this.$http.defaults.baseURL + this.$http.defaults.selectionAPI + 'api/selection/document/exportPersonRegisterDoc?personId=' + this.params.personId)
    },
    exportdoc2 () {
      let url = this.$http.defaults.selectionAPI + 'api/selection/document/exportCygbda?personId=' + this.params.personId
      // console.log(url)
      this.$http.get(url).then(res => {
        if (res.data.success === true) {
          this.download(res.data.result)
        } else {
          this.$message({
            message: '数据获取失败',
            type: 'error'
          })
        }
      })
      // window.open(this.$http.defaults.baseURL + this.$http.defaults.selectionAPI + 'api/selection/document/exportDhjlb?batchId=' + id)
    },
    download (fileid) {
      var downloadElement = document.createElement('a')
      downloadElement.href = this.$http.defaults.baseURL + this.$http.defaults.selectionAPI + 'api/gen/file/download?id=' + fileid
      document.body.appendChild(downloadElement)
      downloadElement.click() // 点击下载
      document.body.removeChild(downloadElement) // 下载完成移除元素
    },
    formatSuccList (fileList) {
      if (fileList && fileList.length > 0) {
        let newfiles = []
        for (let i = 0; i < fileList.length; i++) {
          if (fileList[i].response) {
            newfiles.push({name: fileList[i].response.result[0].fileName + '.' + fileList[i].response.result[0].fileType, id: fileList[i].response.result[0].id})
          } else {
            newfiles.push(fileList[i])
          }
        }
        console.log(newfiles)
        return newfiles
      }
    },
    handleUploadSucc (response, file, fileList) {
      console.log(response)
      if (response.success) {
        this.files.push(response.result[0])
        this.fileList = this.formatSuccList(fileList)
        this.$message({
          message: '上传成功！' + response.message,
          type: 'success'
        })
      } else {
        this.$message({
          message: '上传失败:' + response.message,
          type: 'error'
        })
      }
    },
    beforeRemove (file, fileList) {
      return this.$confirm(`确定移除 ${file.name}？`)
    },
    handleRemove (file, fileList) {
      console.log(file, fileList)
      let fid = file.id
      let url = this.$http.defaults.selectionAPI + 'api/gen/file/remove'
      this.$http.get(url, {
        params: {
          id: fid
        }
      }).then(res => {
        console.log('删除成功:', res)
        if (res.data.success === true) {
          let newfiles = []
          for (let i = 0; i < this.files.length; i++) {
            if (this.files[i].id !== fid) {
              newfiles.push(this.files[i])
            }
          }
          this.files = newfiles
          this.fileList = this.formatFiles(this.files)
          this.$message({
            message: '删除成功！',
            type: 'success'
          })
        }
      })
    },
    uploadError (err) {
      console.log(err)
      this.$message({
        message: '上传失败:' + err,
        type: 'error'
      })
    },
    getftsb (personid) {
      if (personid) {
        this.loading = true
        let url = this.$http.defaults.selectionAPI + 'api/selection/necessary/getPersonStepInfo'
        this.$http.post(url, {
          personId: personid
        }).then(response => {
          console.log('ftsb:', response)
          if (response.data.success) {
            let result1 = ''
            let result2 = ''
            let result3 = ''
            let result4 = ''
            if (response.data.result.stateCadreArchives === -1 || response.data.result.resultCadreArchives === '' || !response.data.result.resultSolicitingOpinions) {
              result1 = '无'
            } else {
              result1 = response.data.result.resultCadreArchives
            }
            if (response.data.result.statePersonalMatters === -1 || response.data.result.resultPersonalMatters === '' || !response.data.result.resultSolicitingOpinions) {
              result2 = '无'
            } else {
              result2 = response.data.result.resultPersonalMatters
            }
            if (response.data.result.stateSolicitingOpinions === -1 || response.data.result.resultSolicitingOpinions === '' || !response.data.result.resultSolicitingOpinions) {
              result3 = '无'
            } else {
              result3 = response.data.result.resultSolicitingOpinions
            }
            if (response.data.result.stateClueReporting === -1 || response.data.result.resultClueReporting === '' || !response.data.result.resultSolicitingOpinions) {
              result4 = '无'
            } else {
              result4 = response.data.result.resultClueReporting
            }
            this.ftsb[0].ftsb1 = result1
            this.ftsb[0].ftsb2 = result2
            this.ftsb[0].ftsb3 = result3
            this.ftsb[0].ftsb4 = result4
          } else {
            this.$message({
              message: '获取失败:' + response.data.message,
              type: 'error'
            })
          }
          this.loading = false
        }).catch(error => {
          this.$message({
            message: '网络获取失败:' + error,
            type: 'error'
          })
          this.loading = false
        })
      }
    },
    onSubmit (req) {
      if (req === 1) {
        this.$refs['kaochaForm'].validate((valid) => {
          if (valid) {
            if (this.kaochaForm.num !== this.kaochaForm.num2 + this.kaochaForm.num3 + this.kaochaForm.num4) {
              this.$message({
                message: '参加考察谈话总人数和同意人数、不同意人数、弃权人数之和不等',
                type: 'warning'
              })
              return
            }
            if (this.kaochaForm.problem === 1) {
              if (this.kaochaForm.hasproblem === '') {
                this.$message({
                  message: '请填写存在问题',
                  type: 'warning'
                })
                return
              }
            }
            // 获取上传文件id

            let arr = []
            for (let i of this.files) {
              arr.push(i.id)
            }
            console.log('文件上传ids:', arr)
            let para = {
              busCandidatePersonId: this.params.personId,
              examinationRange: JSON.stringify(this.kaochaForm.examinationRange),
              teamMembers: this.kaochaForm.name,
              examinationDate: this.kaochaForm.date[0],
              finishTime: this.kaochaForm.date[1],
              noTotal: this.kaochaForm.num,
              noDisagreement: this.kaochaForm.num2,
              noAgreed: this.kaochaForm.num3,
              noAbstentions: this.kaochaForm.num4,
              remarks: this.kaochaForm.beizhu,
              importantSituation: this.kaochaForm.zyqk,
              report: this.kaochaForm.rqbg,
              verifyUserName: this.kaochaForm.hcr,
              verifyTime: this.kaochaForm.date2,
              hasProblem: this.kaochaForm.problem,
              problemComment: this.kaochaForm.hasproblem,
              stateExamination: req,
              files: arr
            }
            this.postSubmit(para, req)
          }
        })
      } else {
        let para = {
          busCandidatePersonId: this.params.personId,
          remarks: this.kaochaForm.beizhu,
          stateExamination: req
        }
        this.postSubmit(para, req)
      }
    },
    postSubmit (para, req) {
      this.submitloading = true
      this.$http.post(this.$http.defaults.selectionAPI + 'api/selection/examination/saveInfo', para).then(res => {
        this.submitloading = false
        if (res.data.success) {
          if (req === 0) {
            this.$message({
              message: '暂存成功',
              type: 'success'
            })
          } else {
            if (this.inRoles(this.userRoles, 'ROLE_banshirenyuan')) {
              this.$message({
                message: '已办理完成并发送给干部处处长',
                type: 'success'
              })
            } else {
              this.$message({
                message: '保存成功',
                type: 'success'
              })
            }
          }
          if (this.inRoles(this.userRoles, 'ROLE_banshirenyuan')) {
            this.$router.push({
              name: 'kaochacn'
            })
          } else {
            if (this.params.edit) {
              this.$router.push({
                name: 'kaocha',
                params: {
                  step: 3
                }
              })
            } else {
              this.$router.push({
                name: 'kaocha',
                params: {
                  step: 1
                }
              })
            }
          }
        } else {
          this.$message({
            message: '保存失败:' + res.data.message,
            type: 'error'
          })
        }
      })
    },
    formatFiles (files) {
      if (files && files.length > 0) {
        let newfiles = []
        for (let i = 0; i < files.length; i++) {
          newfiles.push({name: files[i].fileName + '.' + files[i].fileType, id: files[i].id})
        }
        console.log(newfiles)
        return newfiles
      }
    },
    getKaochaData (id) {
      this.pageloading = true
      let url = this.$http.defaults.selectionAPI + 'api/selection/examination/getInfo'
      this.$http.get(url, {
        params: {
          personId: id
        }
      }).then(res => {
        this.pageloading = false
        console.log('kaochad2 data:', res)
        if (res.data.success === true) {
          let rs = res.data.result
          let arr = {}
          arr.name = rs.teamMembers
          arr.examinationRange = JSON.parse(rs.examinationRange)
          arr.date = rs.examinationDate
          arr.finishTime = rs.finishTime
          arr.date2 = rs.verifyTime
          arr.num = rs.noTotal
          arr.num2 = rs.noDisagreement
          arr.num3 = rs.noAgreed
          arr.num4 = rs.noAbstentions
          arr.beizhu = rs.remarks
          arr.ftsb = this.ftsb
          arr.zyqk = rs.importantSituation
          arr.rqbg = rs.report
          arr.hcr = rs.verifyUserName
          arr.problem = rs.hasProblem
          arr.hasproblem = rs.problemComment
          this.kaochaForm = arr
          // 获取上传文件列表
          // let brr = []
          // for (let i of rs.files) {
          //   brr.push({
          //     name: i.fileName + '.' + i.fileType,
          //     url: this.$http.defaults.baseURL + this.$http.defaults.selectionAPI + 'api/gen/file/download?id=' + i.id
          //   })
          // }
          // this.fileList = brr
          this.workgrouparr = rs.teamMembers.split('、')

          if (rs.files) {
            this.files = rs.files
            this.fileList = this.formatFiles(this.files)
          } else {
            this.files = []
            this.fileList = []
          }
        }
      })
    },
    inRoles (roles, str) {
      console.log(str)
      // arr = 'aaabbROLE_admin'
      if (roles.indexOf(str) === -1) {
        return false
      } else {
        return true
      }
    },
    getConfines () {
      this.$http
        .get(this.$http.defaults.selectionAPI + `api/sysDict/getByCode?code=13`)
        .then(response => {
          if (response.data.success) {
            this.confines = response.data.result
            for (let item of this.confines) {
              item.value = item.label
            }
          } else {
            this.$message({
              message: '获取失败:' + response.data.message,
              type: 'error'
            })
          }
        })
        .catch(error => {
          console.log(error)
          this.$message({
            message: '网络获取失败:' + error,
            type: 'error'
          })
        })
    },
    tableresize (obj) {
      var clientHeight = 0
      if (document.body.clientHeight && document.documentElement.clientHeight) {
        clientHeight = (document.body.clientHeight < document.documentElement.clientHeight) ? document.body.clientHeight : document.documentElement.clientHeight
      } else {
        clientHeight = (document.body.clientHeight > document.documentElement.clientHeight) ? document.body.clientHeight : document.documentElement.clientHeight
      }
      obj.$nextTick(function () {
        obj.tableHeight = clientHeight - 165
      })
    }
  },
  mounted () {
    this.getConfines()
    this.getAllUser()
    this.userRoles = JSON.parse(localStorage.getItem('Roles'))
    this.params = this.$route.params
    this.realName = this.params.realName
    this.unitName = this.params.unitName
    this.jobName = this.params.jobName
    this.jobLevel = this.params.jobLevel
    console.log('kaocha mounted params:' + this.kaochaForm.realName)
    if (this.params.busCandidatePersonId) {
      this.params.personId = this.params.busCandidatePersonId
    }
    this.getKaochaData(this.params.personId)

    // 获取凡提四必数据
    this.getftsb(this.params.personId)

    this.tableresize(this)
    let _this = this
    window.onresize = function windowResize () {
      // 通过捕获系统的onresize事件触发我们需要执行的事件
      _this.tableresize(_this)
    }
  }
}
</script>
<style>
.kaocha-detail .el-table--border td, .el-table--border th, .el-table__body-wrapper .el-table--border.is-scrolling-left~.el-table__fixed{
  border-bottom:1px solid #95B8E7;
}
.kaocha-detail .el-table td, .el-table th.is-leaf{
  border-right:1px solid #95B8E7;
}
.kaocha-detail .wboxnoborder .el-table{
  border: #95B8E7 solid 1px;
}
.kaocha-detail .wboxnoborder .el-table th{
  font-weight: normal;
  background-image: linear-gradient(to bottom , #f8f8f8, #efefef);
  text-align: center;
  border-right: #95B8E7 solid 1px;
  border-bottom: #95B8E7 solid 1px;
  min-height: 30px;
  line-height:30px;
}
.kaocha-detail .wboxnoborder .el-table td, .el-table th{
  padding:0;
  font-size:var(--size14) !important;
  line-height: 20px;
  font-family: '宋体';
  text-align: center;
}
.kaocha-detail .el-table__row{
  height: 50px;
}
.kaocha-detail .el-form--inline .el-form-item__content{
  font-weight: bolder
}
.kaocha-detail .el-form--inline .el-form-item__content{
  font-weight: bolder
}
.kaocha-detail .el-tag.el-tag--info {
  color:#000
}
.kaocha-detail .el-tag,.kaocha-detail  .el-progress-bar__innerText {
  font-size:var(--size16) !important;
}
</style>
<style scoped>
.kaocha-detail {
  width: 100%;
}
.sel-tit {
  height: 32px;
  line-height: 32px;
  padding: 0 15px;
  box-sizing: border-box;
  float: left;
  color: #303133;
  text-align: right;
  font-size: 16px;
}
.sel-con {
  width: 100%;
  height: 32px;
  line-height: 32px;
  padding: 0 15px;
  box-sizing: border-box;
  float: left;
  color: #909399;
  border-bottom: 0.5px solid #909399;
  font-size: 14px;
}
.sel-fl {
  float: left;
}
.kaocha-detail .wboxnoborder {
  padding: 0;
  width: 100%;
  background-color: #fff;
  margin: 0 10px;
  overflow: hidden;
}
</style>
